﻿<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>作业1</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    #box {
      width: 328px;
      height: 522px;
      background: #006699;
      margin: 0 auto;
      margin-top: 100px;
    }

    #box-1 {
      width: 300px;
      height: 500px;
      float: left;
      margin: 11px 14px;
      background: #fff;
    }

    header {
      width: 100%;
      text-align: center;
    }

    h2 {
      letter-spacing: 6px;
      padding-top: 13px;
      padding-bottom: 13px;
      color: #888888;
      font-weight: bold
    }

    header p {
      font-size: 13px;
      color: #888888;
    }

    form {
      margin-top: 31px;
    }

    input {
      height: 46px;
      width: 260px;
      margin: 6px 20px;
      border: 1px solid #ccc;
      border-radius: 4px;
    }

    ::-webkit-input-placeholder {
      padding-left: 20px;
    }

    input[type=data]::-webkit-input-placeholder {
      color: #000;
    }

    input[type=submit] {
      background: #2376bc;
      color: #fff;
      letter-spacing: 4px;
      font-weight: bold;
    }

    footer {
      text-align: center;
    }

    footer h4 {
      line-height: 96px;
      color: #000;
      font-weight: normal
    }

    footer h4 a {
      color: #0000ee;
    }

  </style>
</head>

<body>
  <div id="box">
    <div id="box-1">
      <header>
        <h2>日考测试</h2>
        <p>对新增元素，新增属性的测试案例</p>
      </header>
      <section>
        <form>
          <input type="text" placeholder="请输入用户名" class="name"><br>
          <input type="email" class="email" placeholder="请输入您常用的邮箱地址" required><br>
          <input type="number" class="number" placeholder="请输入您的真实年龄" max="120" required><br>
          <input type="data" class="data" placeholder=" 年 / 月 / 日 " required="*"><br>
          <input type="submit" class="save">
        </form>
      </section>
      <footer>
        <h4>已有账号<a href="#">登录</a></h4>
      </footer>
    </div>

  </div>
</body>
<script src="js/jquery-1.12.4.min.js"></script>
<script>
  $('.save').on('click', function (e) {
    e.preventDefault();
    var obj = {
      name: $('.name').val(),
      email: $('.email').val(),
      number: $('.number').val(),
      data: $('.data').val()
    }
    localStorage.clear();
    var all = localStorage.getItem('list')
    if (all) {
      all = JSON.parse(all);
      all.push(obj);
      localStorage.setItem('list', JSON.stringify(all));
    } else {
      localStorage.setItem('list', JSON.stringify([obj]));
    }
    console.log(localStorage)

  });
  // 这是我给路北这个臭弟弟演示的

</script>

</html>
